<?php
/**
 * Created by PhpStorm.
 * User: gesangdianzi
 * Date: 2022/10/31
 * Time: 10:28
 */
namespace app\common\enum;

use MyCLabs\Enum\Enum;
use yii\helpers\ArrayHelper;

class BaseEnum extends Enum
{
    public static $msg = [
    ];

    public static function getMsg($value){
        return ArrayHelper::getValue(static::$msg,$value,$value);
    }

    public static function toOptions($is_value = true){
        $arr = static::values();
        $re = [];
        if($arr){
            foreach ($arr as $value){
                if($is_value){
                    $re[$value->getValue()] = $value->getValue();
                }else{
                    $re[$value->getValue()] = static::getMsg($value->getValue());
                }
            }
        }
        return $re;
    }
}